//
//  NativeView.m
//  NavigationDemo
//
//  Created by 商广硕 on 2022/7/16.
//

#import "NativeView.h"

@implementation NativeView

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/
+ (instancetype)loadView {
    NativeView* navView = [[NSBundle mainBundle] loadNibNamed:@"NativeView" owner:self options:nil].firstObject;
    if ([self isNotchScreen]) {
        navView.frame = CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, 88);
    }else{
        navView.frame = CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, 64);
    }
   
    navView.backgroundColor = [UIColor brownColor];
    [navView.backBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    [navView.backBtn setTitle:@"返回" forState:UIControlStateNormal];
    [navView.rightBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    [navView.rightBtn setTitle:@"" forState:UIControlStateNormal];
    
    return  navView;
}
+ (BOOL)isNotchScreen {
    
    if ([UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPad) {
        return NO;
    }
    
    CGSize size = [UIScreen mainScreen].bounds.size;
    NSInteger notchValue = size.width / size.height * 100;
    
    if (216 == notchValue || 46 == notchValue) {
        return YES;
    }
    
    return NO;
}
@end
